<template>
    <el-row type="flex" justify="center" align="middle" style="margin-top: 20px;">
      <el-col :span="12">
        <div class="centered">
          <el-tabs type="border-card">
            <el-tab-pane label="账号">
              <UserInfo />
            </el-tab-pane>
            <el-tab-pane label="农场信息">
              <el-row type="flex" justify="center" align="middle" styl e="margin-top: 20px;">
                <el-col :span="12">
                  <el-form :model="farmer" ref="farmer" label-width="80px" :inline="false" size="normal">
                    <el-form-item label="农场名称">
                      <el-input v-model="farmer.farmName"></el-input>
                    </el-form-item>
                    <el-form-item>
                      <el-button type="primary" @click="onSubmit">确认修改</el-button>
                    </el-form-item>
                  </el-form>
  
                </el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="位置">
              <LocationComp />
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-col>
    </el-row>
  </template>
  
  <script>
  import UserInfo from "@/components/UserInfo";
  import LocationComp from "@/components/LocationComp";
  export default {
    created() {
      this.form = this.$store.getters.currentUser;
      this.$axios.get('/farmer/' + this.form.id).then(
        res => {
          if (res.code === 200) {
            console.log(res.data)
            this.farmer = res.data
          }
        }
      )
    },
    components: {
      UserInfo,LocationComp
    },
    data() {
      return {
        farmer: null
      }
    },
    methods: {
      onSubmit() {
        this.$axios.post('/farmer', this.farmer).then(
          res => {
            if (res.code === 200) {
              this.$message.success("修改OK")
            }
          }
        )
      }
    }
  }
  </script>